package com.sunwoda.springbootredis.controller;

import com.sunwoda.springbootredis.entity.ResultEntity;
import com.sunwoda.springbootredis.entity.User;
import com.sunwoda.springbootredis.entity.UserAddress;
import com.sunwoda.springbootredis.result.Result;
import com.sunwoda.springbootredis.service.UserAddressService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (UserAddress)表控制层
 *
 * @author makejava
 * @since 2021-09-22 21:57:38
 */
@RestController
@RequestMapping("userAddress")
public class UserAddressController {
    /**
     * 服务对象
     */
    @Resource
    private UserAddressService userAddressService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public UserAddress selectOne(Integer id) {
        return this.userAddressService.queryById(id);
    }


    /**
     * @Description: update
     * @Param:
     * @return:
     * @Author: SGR
     * @Date: 2021-09-23
     */
    @PutMapping(value = "/update")
    public ResultEntity update(@RequestBody UserAddress re){
        int update = this.userAddressService.update(re);
        if (update <= 0){
            return Result.customFail(update);
        }
        return Result.customSuccess(update);
    }


}